﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace f1
{
    public partial class Form_add : Form
    {
        int num;
        String product;
        String customer;
        double price;
        public Form_add()
        {
            InitializeComponent();
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void num_txt_TextChanged(object sender, EventArgs e)
        {
            try
            {
                this.num = Convert.ToInt32(num_txt.Text);
            }
            catch
            {

            }
        }

        private void btn_ok_add_Click(object sender, EventArgs e)
        {
            try
            {                                            
                if (OrderService.addOrder(this.num, this.product, this.customer, this.price))
                {
                    //添加成功
                    DialogResult result = MessageBox.Show("添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Close();
                }
                else
                {
                    DialogResult result = MessageBox.Show("添加失败1", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //添加失败
                }
            }
            catch
            {
                DialogResult result = MessageBox.Show("添加失败2", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //添加失败
            }
        }

        private void product_txt_TextChanged(object sender, EventArgs e)
        {
            this.product = product_txt.Text;
        }

        private void txt_customer_TextChanged(object sender, EventArgs e)
        {
            this.customer = txt_customer.Text;
        }

        private void txt_price_TextChanged(object sender, EventArgs e)
        {
            try
            {
                this.price = Convert.ToDouble(txt_price.Text);
            }
            catch
            {

            }
        }
    }
}
